<!DOCTYPE html>
<html class="x-admin-sm">

<head>
    <meta charset="UTF-8">
    <title>维保人员管理页面</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi"/>
    <link rel="stylesheet" href="./css/font.css">
    <link rel="stylesheet" href="./css/xadmin.css">
    <script src="./lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="./js/xadmin.js"></script>
    <!--[if lt IE 9]>
    <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
    <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>

<body>
<div class="x-nav">
            <span class="layui-breadcrumb">
                <a>
                    <cite>维护人员</cite></a>
            </span>
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right"
       onclick="location.reload()" title="刷新">
        <i class="layui-icon layui-icon-refresh" style="line-height:30px"></i>
    </a>
</div>
<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-body ">
                    <form class="layui-form layui-col-space5">
                        <div class="layui-inline layui-show-xs-block">
                            <input class="layui-input" autocomplete="off" placeholder="用户名 " name="cname" id="cname">
                        </div>
                        <div class="layui-inline layui-show-xs-block">
                            <input class="layui-input" autocomplete="off" placeholder="姓名 " name="name" id="name">
                        </div>
                        <div class="layui-inline layui-show-xs-block">
                            <input class="layui-input" autocomplete="off" placeholder="微信号" name="openid"
                                   id="openid"></div>
                        <div class="layui-inline layui-show-xs-block">
                            <input class="layui-input" autocomplete="off" placeholder="手机号" name="tel" id="tel">
                        </div>
                        <div class="layui-inline layui-show-xs-block">
                            <button class="layui-btn" lay-submit="" lay-filter="search">
                                <i class="layui-icon">&#xe615;</i></button>
                        </div>
                    </form>
                </div>
            </div>

            <div class="layui-card-body ">
                <table class="layui-table"
                       lay-data="{url:'./baoxiumanList',page:true,toolbar: '#toolbarDemo',id:'test'}"
                       lay-filter="test">
                    <thead>
                    <tr>
                        <th lay-data="{type:'checkbox'}">ID</th>
                        <th lay-data="{field:'cname',  width: 80}">登录名</th>
                        <th lay-data="{field:'name',  width: 80}">姓名</th>
                        <th lay-data="{field:'openid',width:140}">微信</th>
                        <th lay-data="{field:'status', width:140,templet:function(p){
                            if(p.status ==1){
                                return '正常';
                            }
                            return '已停用';
                        }}">状态
                        </th>
                        <th lay-data="{field:'tel',width:140, sort: true}">手机号</th>
                        <th lay-data="{field:'yzm', width:140}">验证码</th>
                        <th lay-data="{templet: '#rowBtn',minWidth:360,fix:'right'}">操作</th>
                        <!-- <th lay-data="{field:'unitid', sort: true, edit: 'text'}">单位号</th>-->
                    </tr>
                    </thead>
                </table>
            </div>
        </div>
    </div>
</div>
</div>
</body>
<script type="text/html" id="toolbarDemo">
    <div class="layui-btn-container">
        <button class="layui-btn" lay-event="add"><i class="layui-icon"></i>添加
        </button>
    </div>
</script>
<script type="text/html" id="rowBtn">
    <button class="layui-btn layui-btn layui-btn-xs" lay-event="update"><i class="layui-icon">&#xe642;</i>编辑
    </button>
    <button class="layui-btn-danger layui-btn layui-btn-xs" lay-event="updatepass"><i class="layui-icon">&#xe642;</i>改密
    </button>
    <button class="layui-btn-danger layui-btn layui-btn-xs" lay-event="del"><i class="layui-icon">&#xe640;</i>删除
    </button>
</script>
<script>layui.use(['table', 'form', 'layer'],
    function () {
        var table = layui.table;
        var $ = layui.$;
        var form = layui.form;
        var layer = layui.layer;
        //监听搜索事件
        form.on('submit(search)', function (data) {
            table.reload("test", {
                page: {
                    curr: 1
                    //重新从第 1 页开始
                },
                where: data.field
            });
            return false;
        });

    });</script>
<script>layui.use('table',
    function () {
        var table = layui.table;

        //头工具栏事件
        table.on('toolbar(test)',
            function (obj) {
                var checkStatus = table.checkStatus(obj.config.id);
                switch (obj.event) {
                    case 'add':
                        xadmin.open('添加', 'baoxiumanAdd.html', 800, 500);
                        break;
                }
            });
        table.on('tool(test)', function (obj) {
            switch (obj.event) {
                case "update":
                    window.sessionStorage.setItem("bid", obj.data.id);
                    xadmin.open('修改维保人员信息', 'baoxiumanUpdate.html?' + obj.data.id, 800, 500);
                    break;
                case "del":
                    var data = obj.data;
                    layer.confirm('确定删除吗？', function (index) {
                        delBaoXiuMan(data, index, obj);
                    });
                    break;
                case "updatepass":
                    xadmin.open('修改维保人员密码', 'baoxiumanUpdatePass.html?' + obj.data.id, 800, 400);
                    break;
            }
        });

        function delBaoXiuMan(data, index, obj) {
            var id = obj.data.id;
            $.get("delBaoXiuMan", {id: id}, function (data) {
                alert(data.msg);
                xadmin.father_reload();
            });
        }
    });
</script>
</html>